home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / (A)Z / (A)Z8.ADF / Muncho / main.c < prev    next >
C/C++ Source or Header  |  1989-06-27  |  2KB  |  127 lines

  1. #include <exec/types.h>
  2. #include <libraries/dos.h>
  3. #include <libraries/dosextens.h>
  4. #include <lattice/stdio.h>
  5. #include <lattice/math.h>
  6. #include <graphics/gfxbase.h>
  7. #include <graphics/rastport.h>
  8. #include <intuition/intuition.h>
  9.  
  10. #include "soundobj.h"
  11.  
  12.     struct IntuitionBase    *IntuitionBase;
  13.     struct GfxBase        *GfxBase;
  14.  
  15.     static struct NewWindow    New_Window = {
  16.         0, 12,
  17.         128, 10,        /* width & height */
  18.         -1, -1,            /* Default pens */
  19.         CLOSEWINDOW        /* IDCMP flags */
  20.             | DISKINSERTED
  21.             | DISKREMOVED,
  22.         WINDOWCLOSE
  23.             | SMART_REFRESH 
  24.             | WINDOWDRAG,
  25.         (struct Gadget *) NULL,
  26.         (struct Image *) NULL,
  27.         (UBYTE *)"Disk Sounds",
  28.         (struct Screen *) NULL,
  29.         (struct BitMap *) NULL,
  30.         10, 17, 640, 400,
  31.         WBENCHSCREEN        /* Of course! */
  32.     };
  33.  
  34.  
  35.  
  36. main(argc,argv)
  37. int argc;
  38. char *argv[];
  39. {
  40.     struct IntuiMessage    *GetMsg();
  41.     struct IntuiMessage    *msg_;
  42.     struct Window        *OpenWindow();
  43.     struct Window        *w_ = NULL;
  44.     struct SOUNDOBJ     *sin_ = NULL;
  45.     struct SOUNDOBJ     *sout_ = NULL;
  46.     int            signal;
  47.     ULONG            msgClass;
  48. /*
  49. Open libraries:
  50. ===============*/
  51.     if(!(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0))){
  52.         exit(1);
  53.     }
  54.     if(!(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0))){
  55.         CloseLibrary(GfxBase);
  56.         exit(1);
  57.     }
  58.     if(audio_init()){
  59.         goto l_exit;
  60.     }
  61. /*
  62. Open a window:
  63. ==============*/
  64.     if(!(w_=OpenWindow(&New_Window))){
  65.         CloseLibrary(GfxBase);
  66.         CloseLibrary(IntuitionBase);
  67.         exit(3);
  68.     }
  69. /*
  70. Load sounds:
  71. ============*/
  72.     if(argc != 3){
  73.         if(!(sin_=SOCreate("crunch"))){
  74.             goto l_exit;
  75.         }
  76.         if(!(sout_=SOCreate("sneeze"))){
  77.             goto l_exit;
  78.         }
  79.     }
  80.     else{
  81.         if(!(sin_=SOCreate(argv[1]))){
  82.             goto l_exit;
  83.         }
  84.         if(!(sout_=SOCreate(argv[2]))){
  85.             goto l_exit;
  86.         }
  87.     }
  88. /*
  89. Wait for messages:
  90. ==================*/
  91.     while(1){
  92.         msgClass = 0x0;
  93.         signal = Wait(1 << w_->UserPort->mp_SigBit);
  94.         while(msg_=GetMsg(w_->UserPort)){
  95.             msgClass |= msg_->Class;
  96.             ReplyMsg(msg_);
  97.         }
  98.         if(msgClass & DISKINSERTED){
  99.             SOSound(sin_);
  100.         }
  101.         if(msgClass & DISKREMOVED){
  102.             SOSound(sout_);
  103.         }
  104.         if(msgClass & CLOSEWINDOW){
  105.             break;
  106.         }
  107.     }
  108. /*
  109. Exit:
  110. =====*/
  111. l_exit:
  112.     audio_close();
  113.     if(sin_){
  114.         SODelete(sin_);
  115.     }
  116.     if(sout_){
  117.         SODelete(sout_);
  118.     }
  119.     if(w_){
  120.         CloseWindow(w_);
  121.     }
  122.     CloseLibrary(GfxBase);
  123.     CloseLibrary(IntuitionBase);
  124.     exit(0);
  125. }
  126.  
  127.